package com.app.micaihu.view.home.arms.presenter

import com.app.base.mvp.BasePresenter
import com.app.http.NetRequestListener
import com.app.http.bean.BaseBean
import com.app.micaihu.configure.LoadType
import com.app.micaihu.view.bean.Arms
import com.app.micaihu.view.home.arms.contract.ArmsContract
import com.app.micaihu.utils.ApiServiceUtils.apiService
import com.app.micaihu.utils.ParamsMapUtils

/**
 * @author
 * @date 2020
 */
open class ArmsPresenter : BasePresenter<ArmsContract.View>(), ArmsContract.Presenter {

    override fun arms() {
        val params = ParamsMapUtils.commonParams
        requestNetwork(apiService.arms(params), object : NetRequestListener<BaseBean<Arms?>?> {
            override fun onSuccess(result: BaseBean<Arms?>?) {
                getView()?.handleArms(result, LoadType.TYPE_REFRESH_SUCCESS)
            }

            override fun onFailed(e: Throwable?) {
                getView()?.handleArms(null, LoadType.TYPE_REFRESH_ERROR)
                getView()?.onError(e)
            }

        })
    }
}